package ControlLayer;
import ExceptionsPackage.*;
import ModelLayer.*;

public class CustomerCtr
{
	private CustomerCon customerCon;
	
	public CustomerCtr()
	{
		customerCon = customerCon.getInstance();
	}
	
	public CustomerCon getCustomerCon()
	{
		return customerCon;
	}
	
	public void createCustomer(int id, String name, String address, String phone, String mail, String CPRnr) throws MatchingIdException
    {
        if(customerCon.getCustomer(id) == null)
        {
            Customer newCustomer = new Customer(id, name, address, phone, mail, CPRnr);
            customerCon.addCustomer(newCustomer);
        }
        else
        {
            throw new MatchingIdException("Der findes allerede en kunde med ID: "+ id +" i systemet.");
        }
    }
	
    public void createBusinessCustomer(int id, String name, String address, String phone, String mail, String companyName, String CVRnr, double discount) throws MatchingIdException
    {
        if(customerCon.getBusinessCustomer(id) == null)
        {
            BusinessCustomer newBusinessCustomer = new BusinessCustomer(id, name, address, phone, mail, companyName, CVRnr, discount);
            customerCon.addBusinessCustomer(newBusinessCustomer);
        }
        else
        {
        	throw new MatchingIdException("Der findes allerede en forretningskunde med ID: "+ id +" i systemet.");
        }
    }
    
    public Customer getCustomer(int id)
    {
        return customerCon.getCustomer(id);
    }
    
    public BusinessCustomer getBusinessCustomer(int id)
    {
        return customerCon.getBusinessCustomer(id);
    }
    
    public void removeCustomer(int id)
    {
        customerCon.removeCustomer(id);
    }
    
    public void removeBusinessCustomer(int id)
    {
        customerCon.removeBusinessCustomer(id);
    }
}
